package com.robot.common.utils;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;

/**
 * 生成短信验证码工具类
 */
public class VerificationCodeUtils {

    /**
     * 生成6位随机验证码
     */
    public static String  generateCustomVerificationCode() {
        //TODO：线程安全问题

        /**参数分别是宽、高、验证码个数，横线干扰个数**/
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(300, 100, 6, 10);
        /**只会在0-9中产生验证码的内容，内容个数为6**/
        RandomGenerator randomGenerator = new RandomGenerator("0123456789", 6);
        lineCaptcha.setGenerator(randomGenerator);
        String lineCaptchaCode = lineCaptcha.getCode();
        return lineCaptchaCode;

    }

}
